package com.example.healthmanagement.ui.fragment;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;

import com.example.healthmanagement.R;
import com.example.healthmanagement.bean.BMIResult;
import com.example.healthmanagement.ui.activity.BmiCalculateActivity;
import com.example.healthmanagement.ui.activity.DietActivity;
import com.example.healthmanagement.ui.activity.FoodEnergyActivity;
import com.example.healthmanagement.ui.activity.HealthRecordActivity;
import com.example.healthmanagement.ui.activity.LoseWeightActivity;
import com.example.healthmanagement.ui.activity.SportRecordActivity;
import com.example.healthmanagement.ui.activity.WeightRecordActivity;
import com.example.healthmanagement.util.MySqliteOpenHelper;
import com.example.healthmanagement.util.OkHttpTool;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * 首页
 */
public class HomeFragment extends Fragment {
    MySqliteOpenHelper helper = null;
    private Activity myActivity;
    private LinearLayout ll_food_energy;
    private LinearLayout ll_weight;
    private LinearLayout ll_diet;
    private LinearLayout ll_lose_weight;
    private LinearLayout ll_health_record;
    private LinearLayout ll_sport_record;
    private LinearLayout ll_bmi_calculate;
    private Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        myActivity = (Activity) context;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
        helper = new MySqliteOpenHelper(myActivity);
        ll_food_energy = view.findViewById(R.id.ll_food_energy);
        ll_weight = view.findViewById(R.id.ll_weight);
        ll_diet = view.findViewById(R.id.ll_diet);
        ll_lose_weight = view.findViewById(R.id.ll_lose_weight);
        ll_health_record = view.findViewById(R.id.ll_health_record);
        ll_sport_record = view.findViewById(R.id.ll_sport_record);
        ll_lose_weight = view.findViewById(R.id.ll_lose_weight);
        ll_bmi_calculate = view.findViewById(R.id.ll_bmi_calculate);
        initView();
        ll_food_energy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(myActivity, FoodEnergyActivity.class);
                startActivity(intent);
            }
        });
        ll_weight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(myActivity, WeightRecordActivity.class);
                startActivity(intent);
            }
        });
        ll_diet.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(myActivity, DietActivity.class);
                startActivity(intent);
            }
        });
        ll_lose_weight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(myActivity, LoseWeightActivity.class);
                startActivity(intent);
            }
        });
        ll_health_record.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(myActivity, HealthRecordActivity.class);
                startActivity(intent);
            }
        });
        ll_sport_record.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(myActivity, SportRecordActivity.class);
                startActivity(intent);
            }
        });
        ll_bmi_calculate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(myActivity, BmiCalculateActivity.class);
                startActivity(intent);
            }
        });

        return view;
    }


    /**
     * 初始化
     */
    private void initView() {

    }


}
